import { globalData } from '../../utils/global-data';

Page({
    onShareAppMessage: function () {
        return {
            title: '邀你一起学：孙子兵法',
            path: '/pages/index/index'
        };
    },
    data: {
        audioInfo: {}, // 正在播放的音频详细数据
        isShow: false,
        images: [
            {
                id: 1,
                url: 'http://img02.tooopen.com/images/20150928/tooopen_sy_143912755726.jpg'
            },
            {
                id: 2,
                url: 'http://img06.tooopen.com/images/20160818/tooopen_sy_175866434296.jpg'
            },
            {
                id: 3,
                url: 'http://img06.tooopen.com/images/20160818/tooopen_sy_175833047715.jpg'
            }
        ],
        interval: 1000,
        nodes: [{
            name: 'a',
            attrs: {
                href: 'http://www.baidu.com',
                target: '_blank',
                class: 'div_class',
                style: 'line-height: 60px; color: red;'
            },
            children: [{
                type: 'text',
                text: 'Hello&nbsp;World!'
            }]
        }],
        strHTML: '<h1>H1</h1><strong>sdfs</strong><img src="http://img02.tooopen.com/images/20150928/tooopen_sy_143912755726.jpg" />'
    },
    onLoad: function (e) {
        console.log('index onLoad');
    },
    onShow: function (e) {
        console.log('index onShow');
        let audioInfo = globalData('audioInfo');
        if (audioInfo) {
            console.log('show audio');
            this.setData({
                isShow: true,
                audioInfo: audioInfo
            });
        }
    },
    onTabItemTap: function (e) {
        console.log('index onTabItemTap');
    },
    handlePayment: function (params) {
        console.log('payment');
        wx.requestPayment({
            'timeStamp': '',
            'nonceStr': '',
            'package': '',
            'signType': 'MD5',
            'paySign': '',
            'success': function (res) {
                console.log('payment success:', JSON.stringify(res));
            },
            'fail': function (res) {
                console.log('payment fail:', JSON.stringify(res));
            }
        });
    }
});
